Skip to content

Run Doctrine migrations automatically on container start (#309) - #310

Open
akramer-zibra wants to merge 3 commits into
tchapi:mainfrom
akramer-zibra:main
Open

akramer-zibra wants to merge 3 commits into
tchapi:mainfrom
akramer-zibra:main

Conversation

@akramer-zibra

Copy link
Copy Markdown

These changes implement Doctrine migrations run on container startup (#309) with additional healthchecks on required docker database services.

@tchapi

tchapi commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Thanks @akramer-zibra

I admit that a forgotten migration fails in confusing ways.

I don't want to merge it as is though, because migrating unconditionally on start conflicts with a few things:

  • My stance that upgrades need a human (backup, release notes, changes of behavior, etc) before the schema changes
  • One-off docker run … bin/console … commands would also trigger migrations
  • The Baïkal migration path (first migration only, then import, then the rest) and pre-v3 upgrades, where a plain migrate is wrong or fails. These users would get a bad schema state or a crash loop (I hope nobody is on v3 still, but well ...)

There are also some technical issues:

  • Dockerfile-standalone has no USER, so the entrypoint runs as root: files created under var/, or the SQLite database on first run, end up root-owned and php-fpm (www-data) can't write to them.
  • The healthchecks can pass during the DB image's init phase (temporary socket-only server), so davis may still start too early on first boot and exit. For MariaDB, healthcheck.sh --connect --innodb_initialized is the recommended check; for Postgres, pg_isready -h 127.0.0.1 -U ${DB_USER} -d ${DB_DATABASE}.
  • The entrypoint should chain to the base image's one (exec docker-php-entrypoint "$@") rather than replace it.

I'm still interested by a separate PR with just the healthchecks + depends_on: condition: service_healthy (with the checks above) which are a good addition

If I ever go the auto-migrate way, it must be behind an opt-in with a loud caveat on risks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants